<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  div {
    padding: 100px;
  }
</style>

<body>
  <div style="background: #ccc;" onclick="alert(this.style.background)">
    <div style="background: green;" onclick="alert(this.style.background)">
      <div style="background: red;" onclick="alert(this.style.background)"></div>
    </div>
  </div>

</body>

</html>